package com.my.attendance.controller;

import com.my.attendance.entity.Leave;
import com.my.attendance.service.ChaxunList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.HttpRetryException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/chaxun")
public class ChaxunServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("utf-8");
            resp.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            ChaxunList chaxunList = new ChaxunList();
            List<Leave> list = chaxunList.getchaxunList();
            req.setAttribute("list", list);
            System.out.println(list);
            req.getRequestDispatcher("/jsp/admin/leave_list.jsp").forward(req, resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
